<?php
declare (strict_types = 1);

namespace app\admin\controller;

use app\admin\logic\BannerLogic;
use app\admin\model\Banner;
use app\BaseController;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Index extends BaseController
{
    public function index()
    {
        return View::fetch();
    }

    public function info()
    {
        return View::fetch();
    }

    public function pass()
    {
        return View::fetch();
    }

    public function adv()
    {

//        判断是否为post接值
        if(Request::isPost()){
            //接post值
            $param = Request::post();
            //输出字段,与数据库对应,对应后可写在模型层,也可直接在html页改name值
//            echo "<pre>";
//            print_r($param);
//            echo "</pre>";
            $data = BannerLogic::getBannerData($param);
            //错误信息
            list($res,$msg)=Banner::addBannnerInfo($data);
            if($res){
                $this->success($msg,url('adv'));
            }else{
                $this->error('网络异常,添加失败');
            }
        }


        //查询数据库所需数据
        $sel=Banner::getBannerSel();
//        echo "<pre>";
//        print_r($sel);
//        echo "</pre>";
        View::assign('sel',$sel);

        return View::fetch();
    }

    public function login()
    {
        return View::fetch();
    }
}
